﻿
Partial Class store_UCAudio
    Inherits System.Web.UI.UserControl


    Public Sub Display(p As CProduct, list As CProductList)
        If Me.Parent.Controls.Count Mod 2 = 1 Then row.Attributes.Add("class", "alt_row")

        If p.IsEnglish Then
            lnkNameChineseSimplified.Visible = False
        Else
            lnkNameChineseSimplified.Text = p.ProductNameChineseSimplified
            lnkNameChineseSimplified.NavigateUrl = CSitemap.Decide(p)
            lnkNameChineseSimplified.ToolTip = p.ProductDescriptionChineseSimplifiedOrParent
        End If

        With lnkDate
            .NavigateUrl = CSitemap.Decide(p)
            .Text = p.ProductCreated.ToString("d-MMM-yy")
            .ToolTip = p.DateString()
            ' .ToolTip &= p.Contents
        End With

        With lnkSpeaker
            .Text = CUtilities.Truncate(p.SpeakerName, 12)
            .NavigateUrl = CSitemap.Audio(Nothing, p.ProductSpeakerId)
        End With

        litTitle.Text = CUtilities.Truncate(p.ProductName, 50)
        With lnkTitle
            .ToolTip = IO.Path.GetFileName(p.Files.FirstMp3.FileName) & vbCrLf & CUtilities.Truncate(p.ProductDescriptionOrParent, 500)

            If p.HasAudio Then
                .NavigateUrl = CConfig.DropboxUrl(p.Files.FirstMp3.FileName)
                Dim filePath As String = CConfig.DropboxPublic & p.Files.FirstMp3.FileName
                If IO.File.Exists(filePath) Then lblSize.Text = CUtilities.FileSize(filePath) '.Text = String.Concat(.Text, " (", CUtilities.FileSize(filePath), ")")
            Else
                .Enabled = False
            End If
        End With
    End Sub
End Class
